using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Ltf.MonitorLizard
{
// hourglass handler
	public class HourGlass : IDisposable
	{
		private Form form;
		private static Dictionary<Form, int> formCount = new Dictionary<Form, int>();

		public HourGlass(Form form)
		{
			this.form = form;
			if (!formCount.ContainsKey(form))
				formCount[form]=0;
			else
				formCount[form]++;
			form.Cursor = Cursors.WaitCursor;
		}

		#region IDisposable Members

		public void Dispose()
		{
			if (formCount[form]--==0)
				form.Cursor = Cursors.Default;
		}

		#endregion
	}
}
